package com.fay.effectivech4;

import java.util.AbstractList;
import java.util.List;
import java.util.Objects;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/2/21 15:45
 * @Version 1.0
 */
public interface SkeletonInterfaceClass {

    static List<Integer> intArrayAsList(int[] a) {
        Objects.requireNonNull(a);
        return new AbstractList<Integer>() {
            @Override
            public Integer get(int index) {
                return a[index];
            }

            @Override
            public Integer set(int index, Integer element) {
                int oldVal = a[index];
                a[index] = element;
                return oldVal;
            }

            @Override
            public int size() {
                return a.length;
            }
        };
    }
}
